package com.qihetimes.earthangel.model.bo;

import com.qihetimes.earthangel.common.ApiException;
import com.qihetimes.earthangel.common.GoodsAge;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 物品创建修改参数
 *
 * @author ：f4cklangzi@gmail.com
 * @date ：Created At 2021/12/12
 */
@Data
public class GoodsBO {
    
    @ApiModelProperty(value = "ID(修改时必传)")
    private String id;
    
    @ApiModelProperty(value = "物品名称")
    private String name;
    
    @ApiModelProperty(value = "原始价格")
    private BigDecimal originalPrice;
    
    @ApiModelProperty(value = "新旧程度")
    private GoodsAge age;
    
    @ApiModelProperty("图片列表")
    private List<String> photoUrlList;
    
    @ApiModelProperty(value = "视频URL")
    private String videoUrl;
    
    @ApiModelProperty(value = "录音URL")
    private String recordUrl;
    
    @ApiModelProperty(value = "详细介绍")
    private String description;
    
    @ApiModelProperty(value = "城市")
    private String city;
    
    @ApiModelProperty(value = "区")
    private String region;
    
    @ApiModelProperty(value = "物品关键词")
    private String keyword;
    
    @ApiModelProperty(value = "物品类别")
    private String category;
    
    @ApiModelProperty(value = "纬度，范围为 -90~90，负数表示南纬")
    private Double latitude;
    
    @ApiModelProperty(value = "经度，范围为 -180~180，负数表示西经")
    private Double longitude;
    
    @ApiModelProperty(value = "物品数量")
    private Integer count;
    
    public List<String> getPhotoUrlList() {
        if (photoUrlList != null && photoUrlList.size() > 9) {
            throw new ApiException("图片最多9张!");
        }
        return photoUrlList;
    }
}
